package com.linkhub.oms.admin.modules.shop.domain.vo;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkhub.oms.entity.ShopEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Description: ShopVO
 * @Author: echo
 * @Date: 2024/3/20 11:13
 * @Version: 1.0
 */
@Data
@ApiModel(value = "ShopVO", description = "ShopVO")
public class ShopVO implements Serializable {

    @ApiModelProperty(value = "系统商店id")
    private String sysShopId;

    @ApiModelProperty(value = "商店名称")
    private String shopName;

    @ApiModelProperty(value = "商店地址")
    private String url;

    @ApiModelProperty(value = "商店logo")
    private String logoUrl;

    @ApiModelProperty(value = "平台：1-shopify；2-shipo")
    private Integer platForm;

    @ApiModelProperty(value = "授权：0-失败；1-成功")
    private Integer authorization;

    @ApiModelProperty(value = "授权描述")
    private String authorizationDesc;

    @ApiModelProperty(value = "授权时间")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime authorizationTime;

    public static ShopVO convert(ShopEntity shopEntity) {
        ShopVO shopVO = new ShopVO();
        shopVO.setSysShopId(shopEntity.getSysShopId());
        shopVO.setShopName(shopEntity.getShopName());
        shopVO.setUrl(shopEntity.getUrl());
        shopVO.setLogoUrl(shopEntity.getLogoUrl());
        shopVO.setPlatForm(shopEntity.getPlatForm().getCode());
        shopVO.setAuthorization(shopEntity.getAuthorization().getCode());
        shopVO.setAuthorizationDesc(shopEntity.getAuthorization().getDesc());
        shopVO.setAuthorizationTime(shopEntity.getAuthorizationTime());

        return shopVO;


    }
}
